// 用户在主体的菜单&权限 - system / hotel
import { DataTypes, UUIDV4 } from 'sequelize';
import { MySqlModel, getSequelize } from '../db';

class UserPermissions extends MySqlModel {

}

UserPermissions.init({
  id: {
    type: DataTypes.UUID, unique: 'id', allowNull: false, defaultValue: UUIDV4, validate: { isUUID: 4 }, primaryKey: true, comment: '主键', editable: false
  },
  user_id: {
    type: DataTypes.UUID, allowNull: false, validate: { isUUID: 4 }, comment: '用户', editable: false
  },
  hotel_id: {
    type: DataTypes.UUID, allowNull: false, validate: { isUUID: 4 }, comment: '组织', editable: false
  },
  permission_id: {
    type: DataTypes.UUID, allowNull: false, validate: { isUUID: 4 }, comment: '权限', editable: false
  },
  created_id: {
    type: DataTypes.UUID, allowNull: false, validate: { isUUID: 4 }, comment: '创建用户', editable: false
  },
  created_at: {
    type: DataTypes.DATE, allowNull: false, editable: false, comment: '创建时间'
  },
  updated_at: {
    type: DataTypes.DATE, allowNull: false, editable: false, comment: '更新时间'
  }
}, {
  sequelize: getSequelize(),
  tableName: 'user_permissions',
  comment: '用户权限'
});

// UserPermissions.associate = (models) => {
//   UserPermissions.belongsTo(models.Country, {
//     targetKey: 'id',
//     foreignKey: 'country_id',
//     constraints: false,
//     as: 'country'
//   });
// };

export default UserPermissions;
